import 'package:flutter/material.dart';

class RadioDemo extends StatefulWidget {
  RadioDemo({Key key}) : super(key: key);

  @override
  _RadioDemoState createState() => _RadioDemoState();
}

class _RadioDemoState extends State<RadioDemo> {
  int _radioGroupA = 0;
  void _handleRadioValueChanged(int value) {
    setState(() {
      _radioGroupA = value;
    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('RadioDemo'),
        elevation: 0.0,
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text('RadioDemoValue: $_radioGroupA'),
          SizedBox(height:16.0),
          RadioListTile(
            value: 0,
            groupValue: _radioGroupA, 
            onChanged: _handleRadioValueChanged,
            title: Text('radioGroupA'),
            subtitle: Text('Description'),
            secondary: Icon(Icons.filter_1),
            selected: _radioGroupA==0,
          ),
          RadioListTile(
            value: 1,
            groupValue: _radioGroupA, 
            onChanged: _handleRadioValueChanged,
            title: Text('radioGroupB'),
            subtitle: Text('Description'),
            secondary: Icon(Icons.filter_1),
            selected: _radioGroupA==1,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Radio(
                value: 0, 
                groupValue: _radioGroupA, 
                onChanged: _handleRadioValueChanged,
                activeColor: Colors.black,
              ),
              Radio(
                value: 1, 
                groupValue: _radioGroupA, 
                onChanged: _handleRadioValueChanged,
                activeColor: Colors.black,
              )
            ],
          )
        ],
      ),
    );
  }
}